@echo off
chcp 65001

rem cppcheck_path:cppcheck目录
rem reportxml_path:xml输出目录
rem sourecode_path:源码目录
rem reporthtml_path:html报告输出目录

set cppcheck_path=D:\check\Cppcheck
set reportxml_path=D:\check\Cppcheck\htmlreport
set sourecode_path=D:\check\Cppcheck\htmlreport\wing-gif-editor-master
set reporthtml_path=D:\check\Cppcheck\htmlreport\CodeQualityReport

rem 判断xml是否存在，如果存在清空err.xml
if exist %reportxml_path%\err.xml echo. >%reportxml_path%\err.xml
cd /d %sourecode_path%
%cppcheck_path%\cppcheck.exe --enable=all --platform=win64 --xml ./ 2>%reportxml_path%/err.xml

rem 初始化html报告输出目录
rmdir /s /q %reporthtml_path% && md %reporthtml_path%
cd /d %reportxml_path%
python.exe cppcheck-htmlreport.py --file=err.xml --title=CodeQualityReport --report-dir=CodeQualityReport --source-dir=%sourecode_path%\.

rem 打开html报告
start %reporthtml_path%\index.html
pause